#include<iostream>
#include<assert.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>


int main()
{
    int pipes[2];
    int ret = pipe(pipes);
    // 现在创建一个管道文件，对应的文件描述符为 3 和 4 
    assert(ret == 0);
     std::cout << "pipes[0] = " << pipes[0]  << std::endl;
     std::cout << "pipes[1] = " << pipes[1]  << std::endl;
    
    int pid = fork();
    if(pid == 0)
    {
       std::cout << "我是子进程" << std::endl;
       //通信的通道已经搭建好，现在只需要在这里进行通信即可
       exit(0);
    }

    int jugdePid = waitpid(pid , nullptr, 0);
    if(jugdePid == pid)
    {
        std::cout << "进程等待成功" << std::endl;
    }

    return 0;
}